<template lang="html">
  <div>test</div>
</template>

<script>
export default {
  methods: {
    init () {
      let re = /f../y
      let str = 'foofoofooofoofoo'
      let result1 = str.match(re)
      console.log(result1, result1.length)
      re.lastIndex = 10
      let result2 = str.match(re)
      console.log(result2)
    },
    symbol () {
      let array = [1, 2, 3]
      let it = array[Symbol.iterator]()
      console.log(it.next())
      console.log(it.next())
      console.log(it.next())
      console.log(it.next())

    },
    unique () {
      let array = [1, 2, 4, 1, 3]
      let set = new Set(array)
      console.log([...set])
    },
    fibonacci () {
      let Fib = {
        [Symbol.iterator] () {
          let n1 = 1, n2 = 1
          return {
            [Symbol.iterator] () {
              return this
            },
            next () {
              let current = n2
              n2 = n1
              n1 = n1 + current
              return {
                value: current,
                done: false
              }
            },
            return (v) {
              console.log('fibonacci sequence abandoned')
              return {
                value: v,
                done: true
              }
            }
          }
        }
      }
      for (let v of Fib) {
        console.log(v)
        if (v > 100) break
      }
    }
  },
  created () {
    // this.init()
    // this.symbol()
    // this.unique()
    this.fibonacci()
  }
}
</script>

<style lang="css">
</style>
